<template>
  <div class="app-container">
    <el-form
      :model="ruleForm"
      :rules="rules"
      ref="ruleForm"
      label-position="right"
      label-width="150px"
      style="margin-left: 30px"
      class="el-form-bottom">
      <div>
        <span>支付宝支付信息配置</span>
        <span class="form-word-hint">
          （购买链接：https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=eefd5k6n）
        </span>
        <el-divider></el-divider>
      </div>
      <el-form-item label="H5合作身份者ID" prop="h5Partner">
        <el-input v-model="ruleForm.h5Partner" style="width: 400px"></el-input>
        <span class="form-word-hint">
          签约的支付宝账号对应的支付宝唯一用户号，以2088开头的16位纯数字组成
        </span>
      </el-form-item>
      <el-form-item label="H5卖家支付宝用户号" prop="h5SellerId">
        <el-input v-model="ruleForm.h5SellerId" style="width: 400px"></el-input>
        <span class="form-word-hint">
          卖家支付宝账号对应的支付宝唯一用户号，以2088开头的纯16位数字
        </span>
      </el-form-item>
      <el-form-item label="H5应用AppId" prop="h5AppId">
        <el-input v-model="ruleForm.h5AppId" style="width: 400px"></el-input>
      </el-form-item>
      <el-form-item label="H5支付宝商户私钥" prop="h5PrivateKey">
        <el-input
          type="textarea"
          v-model="ruleForm.h5PrivateKey"
          style="width: 400px"></el-input>
      </el-form-item>
      <el-form-item label="PC合作身份者ID" prop="pcPartner">
        <el-input v-model="ruleForm.pcPartner" style="width: 400px"></el-input>
        <span class="form-word-hint">
          签约的支付宝账号对应的支付宝唯一用户号，以2088开头的16位纯数字组成
        </span>
      </el-form-item>
      <el-form-item label="PC卖家支付宝账号" prop="pcSellerEmail">
        <el-input
          v-model="ruleForm.pcSellerEmail"
          style="width: 400px"></el-input>
        <span class="form-word-hint">
          支付宝登录账号，格式一般是邮箱或手机号
        </span>
      </el-form-item>
      <el-form-item label="PC商户的私钥" prop="pcPrivateKey">
        <el-input
          v-model="ruleForm.pcPrivateKey"
          style="width: 400px"></el-input>
      </el-form-item>
      <el-form-item label="APPID" prop="appAppid">
        <el-input v-model="ruleForm.appAppid" style="width: 400px"></el-input>
      </el-form-item>
      <el-form-item label="APP商户私钥" prop="appPrivateKey">
        <el-input
          type="textarea"
          v-model="ruleForm.appPrivateKey"
          style="width: 400px"></el-input>
      </el-form-item>
      <el-form-item>
        <div class="fixed-bottom-20">
          <el-button type="primary" @click="submitForm('ruleForm')">
            立即提交
          </el-button>
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { Message } from "element-ui";
import { toEditAliPay, EditAliPay } from "@/api/system";
export default {
  name: "alipayconfig",
  data() {
    return {
      ruleForm: {},
      rules: {
        h5Partner: [
          {
            max: 50,
            message: "不能超过50个字符",
            trigger: "blur",
          },
        ],
        h5SellerId: [
          {
            max: 50,
            message: "不能超过50个字符",
            trigger: "blur",
          },
        ],
        h5AppId: [
          {
            max: 50,
            message: "不能超过50个字符",
            trigger: "blur",
          },
        ],
        pcPartner: [
          {
            max: 50,
            message: "不能超过50个字符",
            trigger: "blur",
          },
        ],
        pcSellerEmail: [
          {
            max: 50,
            message: "不能超过50个字符",
            trigger: "blur",
          },
        ],
        pcPrivateKey: [
          {
            max: 50,
            message: "不能超过50个字符",
            trigger: "blur",
          },
        ],
        appAppid: [
          {
            max: 50,
            message: "不能超过50个字符",
            trigger: "blur",
          },
        ],
      },
    };
  },
  created() {
    toEditAliPay().then((res) => {
      this.ruleForm = res.data.data.payconfigAli;
    });
  },
  methods: {
    submitForm(ruleForm) {
      this.$refs[ruleForm].validate((valid) => {
        if (valid) {
          EditAliPay(this.ruleForm).then((res) => {
            if (!res.data.success) {
              Message.error(res.data.message);
              return;
            }
            Message.success("操作成功");
            return;
          });
        }
      });
    },
  },
};
</script>

<style></style>
